<?php

require_once( dirname(__FILE__).'/../appdata/structures.php' );

function showComboWithTheMonths( $curMonth, $nextMonth, $currentDay )
{  
    $comboStr = "
    <table class=\"dropdownselect\"><tr><td>
    <div class=\"styled-select\">
    <select id=\"selectMonth\">
    <option value=\"$curMonth\">" . getMonthName( $curMonth ) . "</option>" . "
    <option value=\"$nextMonth\">" . getMonthName( $nextMonth ) . "</option>
    </select>
    </div>
    </td></tr></table>
    
    <script type=\"text/javascript\"> 
    $(\"#selectMonth\").change(function()
    {
       var urlStr = '../ajax/kalendar.php';
       urlStr += '?selectedMonth=' + $(\"#selectMonth\").val().toString();";
    
    if (isset( $currentDay ))
    {
        $comboStr .= "urlStr += '&selectedDay=$currentDay'";
    }

    $comboStr .= "
       $(\"#calendar\").load( urlStr ); 
        
    });
    </script>
    ";
    echo( $comboStr );
}

$curMonth = date("n");
$nextMonth = $curMonth == 12 ? 1 : $curMonth + 1;

$curDate = "";
if (isset( $_GET[ 'reservationDate' ] ))
    $curDate = $_GET[ 'reservationDate' ];

$curDate = MyDateTime::fromPqDate( $curDate );
$selectedMonth = $curMonth;
if ($nextMonth == $curDate->month)
    $selectedMonth = $nextMonth;

showComboWithTheMonths( $curMonth, $nextMonth, $curDate->day == 0 ? null : $curDate->day );
echo( "
    <div id = \"calendar\" class = \"calendarClass\"></div>
    
<script type=\"text/javascript\"> 
    $(\"#selectMonth\").val( $selectedMonth );
    $(\"#selectMonth\").change();
</script>
    
" );


echo ("
    
<div class =\"reservationInfo\"> 
Rezervovať možno aj telefonicky na tel. číslo 0918999888. <b>Online rezerváciu je možné zrušiť do 24 hodín</b>, potom už len telefonicky. 
</div>
");

?>
